Skip to content

fix(@angular/ssr): decode pathname when constructing server asset path - #33970

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-ssr-prerender-non-ascii
Aug 31, 2026
Merged

fix(@angular/ssr): decode pathname when constructing server asset path#33970
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-ssr-prerender-non-ascii

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

AngularAppEngine / AngularServerApp resolves prerendered static assets using the raw percent-encoded pathname from new URL(request.url) without decoding. However, during the build, prerendered assets are registered in the manifest under their decoded names (e.g. /مقالات/دليل/index.html). For any prerendered route containing non-ASCII characters or percent-encoded characters, asset lookup fails and requests fall back to server-side rendering or 404.

Issue Number: Closes #33966

What is the new behavior?

The request pathname is decoded using decodeURIComponent in buildServerAssetPathFromRequest before looking up the asset in manifest.assets, ensuring requests for prerendered non-ASCII routes correctly match and serve their prerendered files.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the SSR application to support non-ASCII routes and base hrefs by decoding URI components using decodeURIComponent with fallback handling. It also introduces comprehensive test coverage for non-ASCII paths. The review feedback suggests extracting a safeDecode helper to reduce code duplication and preserve variable immutability, as well as adding an afterEach hook in the tests to restore the manifest state and ensure proper test isolation.

Comment thread packages/angular/ssr/src/app.ts Outdated
Comment thread packages/angular/ssr/test/app_spec.ts
@alan-agius4
alan-agius4 requested a review from clydin August 31, 2026 07:40
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Aug 31, 2026
Ensure that the request pathname is decoded using `decodeURIComponent` when resolving server asset paths in `AngularServerApp`.

Previously, `buildServerAssetPathFromRequest` used the raw percent-encoded `pathname` from `new URL(request.url)` while prerendered assets were registered in the manifest under decoded names. Consequently, prerendered routes with non-ASCII or percent-encoded characters failed asset lookup and fell through to server-side rendering or 404.

Closes angular#33966
@alan-agius4
alan-agius4 force-pushed the fix-ssr-prerender-non-ascii branch from c0f5ed4 to 9582885 Compare August 31, 2026 07:41
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 31, 2026
@alan-agius4
alan-agius4 merged commit 4fa81d4 into angular:main Aug 31, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-ssr-prerender-non-ascii branch August 31, 2026 13:09
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/ssr target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prerendered pages at non-ASCII addresses are built and then never served

2 participants